package com.example.dormitorymanagement.service.impl;



import com.example.dormitorymanagement.exception.AbnormalPermissions;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Service
public class suthorityservice {

    public Map<String,Object> verification(HttpServletRequest request) throws AbnormalPermissions {
        Map<String,Object> map = new HashMap<>();

        HttpSession session = request.getSession();

        String authority = (String) session.getAttribute("authority");

        System.out.println("权限：" + authority);

        if (!authority.contains("高"))
        {
            map.put("stat", false);

            map.put("message", "操作失败，权限不够");

            throw new AbnormalPermissions("权限不够！");


        }

        return map;
    }

}
